package com.jun.common.redis.pubsub;

import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author yuejun.li
 * @date 2024/8/13 16:39:21
 * redis发布者
 */
public class RedisPublisher {

    private final RedisTemplate redisTemplate;

    public RedisPublisher(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    /**
     * 发布消息
     * @param channel 频道
     * @param message 消息
     */
    public void publish(String channel, String message) {
        redisTemplate.convertAndSend(channel, message);
    }
}
